package javaCode.chapter09.codeblock_;

public class CodeBlock01 {
    public static void main(String[] args) {

        Movie movie = new Movie("你好，李焕英");
        Movie movie2 = new Movie("唐探3", 40, "陈思诚");

    }
}

class Movie {
    private String name;
    private double price;
    private String director;

    //3个构造器 构成重载
    //1、下面三个构造器都有相同的语句
    //2、这样看起来比较 冗余
    //3、这时我们可以把相同的语句，放到一个代码块中，即可
    //4、这样我们不管调用哪个构造器，创建对象，都会先调用代码块的内容
    //5、代码块的调用顺序 优先于构造器
    {
        System.out.println("电影屏幕打开...");
        System.out.println("广告开始...");
        System.out.println("电影正式开始...");
    }

    public Movie(String name) {
        System.out.println("Movie(String name) 被调用...");
        this.name = name;
    }

    public Movie(String name, double price) {
        this.name = name;
        this.price = price;
    }

    public Movie(String name, double price, String director) {
        this.name = name;
        this.price = price;
        this.director = director;
    }
}